<template>
	<div class="search-container">
    <header class="title">
      <i @click="back" class="yo-ico">&#xf07d;</i>
      <input @click="clear" v-model="keyword" @keyup.enter="doSearch" :placeholder="this.placeholderValue" type="text">
      <span>.&nbsp;.&nbsp;.</span>
    </header>
    <div v-show="isShowContent" class="content">
      <div class="hotsearch-title">
        <i class="yo-ico">&#xf067;</i>
        <span>热门搜索</span>
      </div>
      <ul class="hotsearch-list">
        <router-link :to="{ name: 'listindex', params: { id: 1, key: list.hotsearch_title}}" tag="li" v-for="(list, index) in hotSearchList" :key="index">
          {{ list.hotsearch_title }}
        </router-link>
      </ul>
    </div>
    <div class="result">
      <router-link class="result-tag" tag="div" :to="{ name: 'listindex', params: { id: 1, key: list.chinese}}" v-for="(list, index) in dataList" :key="index">
        {{list.chinese}}
      </router-link>
    </div>
	</div>
</template>

<script>
import axios from 'axios'
export default {
  data() {
    return {
      placeholderValue: '搜索商品',
      id: 1,
      keyword: '',
      dataList: [],
      isShowContent: true,
      hotSearchList: [
        {
          "hotsearch_title": "金玫瑰庄园干红葡萄酒"
        },
        {
          "hotsearch_title": "奔富"
        },
        {
          "hotsearch_title": "泽巴赫"
        },
        {
          "hotsearch_title": "白马庄园"
        },
        {
          "hotsearch_title": "安第斯钻石"
        },
      ]
    }
  },
  methods: {
    clear() {
      this.placeholderValue = ''
    },
    doSearch() {
      this.isShowContent = ! this.isShowContent
      axios.get(`listprod/product/productfacet/?keyword=${this.keyword}`).then((response) => {
        this.dataList = response.data.result
      })
      this.keyword = ''
    },
    back() {
      this.$router.go(-1)
    }
  },
  computed: {

  },
  mounted() {
  }
}
</script>

<style lang="scss">
@import '../styles/yo/usage/core/reset.scss';
#app {
  .search-container {
    width: 100%;
    height: 100%;
    header {
      width: 100%;
      height: 48px;
      @include border(0 0 1px 0);
      .yo-ico {
        display: inline-block;
        line-height: 48px;
        width: .4rem;
        height: 48px;
        font-size: .16rem;
        text-align: center;
      }
      input {
        height: 36px;
        width: 2rem;
        margin-left: .2rem;
        margin-right: .1rem;
        border-radius: 4px;
        border: 1px solid #D9D9D9;
        // text-align: center;
        background: #f5f5f5;
        font-size: .14rem;
        font-weight: 600;
        padding-left: .06rem;
      }
      span {
        display: inline-block;
        line-height: 48px;
        width: .4rem;
        height: 48px;
        font-size: .2rem;
        text-align: center;
        font-weight: 600;
      }
    }
    .content {
      margin-top: .06rem;
      width: 100%;
      height: 1.4rem;
      padding: .16rem .1rem .16rem .2rem;
      .hotsearch-title {
        color: #999;
        span {
          margin-left: 6px;
        }
      }
      .hotsearch-list {
        @include flexbox();
        @include flex-wrap(wrap);
        width: 3rem;
        li {
          height: .3rem;
          @include border(1px #dedede);
          margin-top: .18rem;
          margin-right: .2rem;
          line-height: .3rem;
          color: #999;
          border-radius: 5px;
          padding-left: 6px;
          padding-right: 6px;
        }

      }
    }
    .result {
      padding-top: .06rem;
      overflow-y: scroll;
      width: 100%;
      height: 5.2rem;
      .result-tag {
        width: 100%;
        height: .4rem;
        line-height: .4rem;
        font-size: .14rem;
        @include border(0 0 1px 0);
      }
    }
  }
}
</style>

